/*
@Time : 2020/7/30 10:12
@Author : lym
@File : Database.go
@Software: GoLand
*/
package common

import (
	"gin-YiStudio-V1/dao/model"
	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/mysql"
)

var DB *gorm.DB
var ERR error

func InitDB() {
	DB, ERR = gorm.Open("mysql", "root:root@tcp(127.0.0.1:3306)/yfwang?charset=utf8&parseTime=True&loc=Local")
	if ERR != nil {
		panic(ERR)
	}
	DB.AutoMigrate(&model.User{})
}

func Init() {
	InitDB()
}
